package com.zem.imos.Entity;

import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableId;
import com.fasterxml.jackson.annotation.JsonIgnore;
import com.zem.imos.Entity.Enum.Gender;
import com.zem.imos.Entity.Enum.Period;
import com.zem.imos.Entity.Enum.RegisterStatus;
import com.zem.imos.Entity.Params.ParamsDoctor;
import com.zem.imos.Entity.Params.ParamsRegister;
import lombok.Data;

@Data
public class Register {
    @TableId(type = IdType.ASSIGN_ID)
    private Long id;
    private Long patientId;
    private Long doctorId;
    private Long timestamp; // 预约点击时间戳 毫秒
    @JsonIgnore
    private RegisterStatus status; // 0是预约挂号状态 1是就诊完成状态 2是过期没有来就诊
    private Long date; // 日期 （挂号当天0点的时间戳）
    private Period period; // 时段 (0上午 1下午）
    public Register ()
    {

    }

    public Register (ParamsRegister params)
    {
        this.id = params.getId();
        this.patientId = params.getPatientId();
        this.doctorId = params.getDoctorId();
        this.timestamp = params.getTimestamp();
        if(params.getStatus()!=null)
        this.setStatus(params.getStatus());
        this.date = params.getDate();
        if(params.getPeriod()!=null)
        this.setPeriod(params.getPeriod());


    }


    public void setStatus(Integer flag){
        switch (flag){
            case 0 :
                this.status = RegisterStatus.Unvisited;
                break; //可选
            case 1 :
                this.status = RegisterStatus.Visited;
                break; //可选
            case 2 :
                this.status = RegisterStatus.Pay;
                break; //可选
            case 3 :
                this.status = RegisterStatus.Overdue;
                break; //可选
            default :
                this.status = RegisterStatus.Unvisited;
        }
    }
    public void setPeriod(Integer flag){
        switch (flag){
            case 0 :
                this.period = Period.Forenoon;
                break; //可选
            case 1 :
                this.period = Period.Afternoon;
                break; //可选
            default :
                this.period = Period.Forenoon;
        }
    }


}
